﻿using Sustainalytics.ClientDW.Synchronization.SyncESGData.AbstractClassesAndInterfaces;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Sustainalytics.SharedEntities.EsgResearch;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.IndicatorTemplateLogic
{
    public class IndicatorTemplateOrchestrator : IComprehensiveEsgSyncOrchestrator<IndicatorTemplate>
    {
        private readonly IComprehensiveEsgIndicatorTemplateQuery indicatorTemplateQuery;
        private readonly IndicatorTemplateCommand indicatorTemplateCommand;

        public IndicatorTemplateOrchestrator(IndicatorTemplateQuery indicatorTemplateQuery, IndicatorTemplateCommand indicatorTemplateCommand)
        {
            this.indicatorTemplateQuery = indicatorTemplateQuery;
            this.indicatorTemplateCommand = indicatorTemplateCommand;
        }

        async Task IComprehensiveEsgSyncOrchestrator<IndicatorTemplate>.OrchestrateAsync(IList<IndicatorTemplate> comprehensiveEsgEntities, IList<Guid> invalidatedCompaniesIds)
        {
            await indicatorTemplateCommand.ExecuteAsync(comprehensiveEsgEntities ?? indicatorTemplateQuery.Get());
        }
    }
}
